package com.lzx.iteam.bean;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;

/**
 * 创建聊天小组时使用
 */
public class ChatContact implements Serializable,Parcelable {
    public ChatContact(String userId, String userName,  String contactId) {
        this.userId = userId;
        this.userName = userName;
        this.contactId = contactId;
    }

    public ChatContact(String userId, String userName, String contactId,String contactImg) {
        this.userId = userId;
        this.userName = userName;
        this.contactId = contactId;
        this.userImg=contactImg;
    }


    public ChatContact() {

    }

    public String userId;
    public String userName;
    public String contactId;
    public String userImg;

    public ChatContact(Parcel source) {
        userId = source.readString();
        userName = source.readString();
        contactId = source.readString();
        userImg = source.readString();

    }


    public String getUserId() {
        return userId;
    }


    public String getUserName() {
        return userName;
    }



    public String getContactId() {
        return contactId;
    }

    public String getUserImg() {
        return userImg;
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof ChatContact) {
            ChatContact chatContact = (ChatContact) o;
            if(!"0".equals(userId)){
                return this.userId.equals(chatContact.userId) && this.userName.equals(chatContact.userName);
            }else{
                return this.contactId.equals(chatContact.contactId) && this.userName.equals(chatContact.userName);
            }
        }
        return super.equals(o);
    }

    @Override
    public int describeContents() {
        return 0;
    }



    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(userId);
        dest.writeString(userName);
        dest.writeString(contactId);
        dest.writeString(userImg);
    }


    public static final Parcelable.Creator<ChatContact> CREATOR = new Creator<ChatContact>() {

        @Override
        public ChatContact[] newArray(int size) {
            // TODO Auto-generated method stub
            return new ChatContact[size];
        }

        @Override
        public ChatContact createFromParcel(Parcel source) {
            // TODO Auto-generated method stub
            return new ChatContact(source);
        }
    };
}
